<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button class="jquery_get">jquery(get)请求</button>
    <button class="jquery_post" >jquery(post)请求</button>
    <button class="jquery_ajax">jquery(ajax)请求</button>

    <p class="requesteMssage"></p>

    <script src="./jquery.min.js"></script>
    <script src="./jqueryNetwork.js"></script>
    <script>
        let netWorkUrl = 'http://localhost:8888';

        $('.jquery_get').click(function(){
            $.get(`${netWorkUrl}/test/third`,'name=张三&age=22',function(result){
                console.log(result);
            })
        })

        $('.jquery_post').click(function(){
            $.post(`${netWorkUrl}/test/fourth`,'name=张三&age=90',function(result){
                console.log(result);
            })
        })

        $('.jquery_ajax').click(function(){
            let url = `${netWorkUrl}/test/third`;
            let type = 'get';
            let data = {name : '张三',age : 66};
            let dataType = 'json';

            jAp(url,type,data,dataType);
        })
         /* 
            dataType 接口的格式方式 
         */
        async function jAp(url,type,data,dataType){
            const result = await jqueryAjaxPromise(url,type,data,);
            $('p').html(result);
            console.log(JSON.parse(result));
        }

    </script>
</body>
</html>